<?php

class Create extends Controller {

	function Create() {
		parent::Controller();
	}

	function index() {
		if( !$this->Account->is_admin() ) {
			redirect( '', 'location');
		}
		if( isset($_POST['submit']) ) {
			$name = trim($this->input->post('name'));
			$description = trim($this->input->post('description'));

			if(empty($name)) {
				$this->error = 'Please enter a name';
			} else if(empty($description)) {
				$this->error = 'Please enter a description';
			} else {
				$this->Departments->create($name, $description);
				redirect('department/view', 'location');
			}	
		}
		$this->load->view('department/create');
	}

}

?>
